//
//  HTPremiumHolidayGuide.swift
//  MagaCore
//
//  Created by MrMessy on 2023/5/23.
//

import SwiftUI
import SDWebImageSwiftUI

struct HTPremiumHolidayGuide: View {

  @Binding var var_adConfig: HTAdConfig?
  @Binding var var_introductorySub: HTSubscribe?
  @State var var_onClose: (() -> Void)? = {}
  @State var var_onChooseMore: (() -> Void)? = {}
  @State var var_onPaySubscribe: ((HTSubscribe) -> Void)? = {sub in}

  var body: some View {
    ZStack{
      VStack{
        ZStack(alignment: .topTrailing){
          WebImage(url: URL(string: var_adConfig!.ht_regularSubImg()))
            .resizable()
            .aspectRatio(contentMode: .fit)
            .frame(width: UIDevice.ht_screenWidth())
            .onTapGesture {
              var_onPaySubscribe!(var_introductorySub!)
            }

          HStack{
            Image("ad_close_white")
              .frame(width: 14, height: 14)
              .padding(20)
          }
          .frame(alignment: .topTrailing)
          .onTapGesture {
            var_onClose!()
          }
        }
        .frame(maxWidth: .infinity)
        .padding(.horizontal, 20)

        HStack{
          Text("Choose more plans")
            .underline()
            .foregroundColor(Color.white)
            .font(.system(size: 12))
            .padding(.top, 30)
        }
        .onTapGesture {
          var_onChooseMore!()
        }
      }
      .frame(maxWidth: .infinity, maxHeight: .infinity)
    }
    .background(Color.black.opacity(0.9))
    .frame(maxWidth: .infinity, maxHeight: .infinity)
  }
}
